

function updateStatus(){
	var status  =   document.getElementById('status').value;
	
	$.ajax({
		type: "POST",
		url: "/ajax.php",
		data: "status=" + status,
		success: function(msg){
			alert(msg);
		},
		error: function(msg){
			alert(msg);
		}
	});
}

function streamPublish(name,url, pic, description){        
	FB.ui({ method: 'feed',
			name: name,
			link: url,
			picture: pic,
			caption: 'EnergySave.bg',
			description: description

		  }, function(response) {
			location.reload();
	   });
		  
		  
		
}
function publishStream(pic,user,like){
	
	
	
$.ajax({
	type: "POST",
	url: "like.php",
	data: "image=" + pic +"&user="+user+"&l="+like,
	success: function(msg){
		if(msg)
		{
			eval(msg);
		}else{
			location.reload();	
		}
		
	},
	error: function(msg){
		alert(msg);
	}
});

$('#like-'+pic).hide();	

}

function logout(){
	
	FB.logout(function(response) {
		  //location.reload();
		  window.location = "logout.php";
		});
}


function login()
{
	
	 FB.login(function(response) {
		 
	   if (response.authResponse) {
		 location.reload();
	   } else {
		 console.log('User cancelled login or did not fully authorize.');
	   }
	   
	 }, {scope: 'email,publish_stream,user_likes'});
}
